package config;

import lombok.Data;
import lombok.ToString;

/**
 * @Description PACKAGE_NAME
 * @Author zhengzetao
 * @Date 2022/9/16 15:24
 */
@Data
@ToString
public class DBConfig extends Config {
    final private static String GROUP = "DataSourceConfig";

    private String url;
    private String username;
    private String password;

    public DBConfig() {
        super(GROUP);
        this.url = getStr("url");
        this.username = getStr("username");
        this.password = getStr("password");
        if (this.url.isBlank()) {
            throw new NullPointerException("数据库连接地址不能为空");
        }
        if (this.username.isBlank()) {
            throw new NullPointerException("数据库连接用户名不能为空");
        }
        if (this.password.isBlank()) {
            throw new NullPointerException("数据库连接密码不能为空");
        }
    }
}
